<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>

async_test(function() {
    var worker = new Worker("resources/worker_language.js");
    worker.onmessage = this.step_func_done(function(e) {
        assert_equals(e.data, 'klingon');
    });
    testRunner.setAcceptLanguages('klingon');
    worker.postMessage("langauge changed");
    done();
}, "Test changing the language on worker threads.");

async_test(function() {
    var worker = new Worker("resources/worker_language_event.js");
    worker.onmessage = this.step_func_done(function(e) {
        assert_equals(e.data, 'language event fired');
    });
    testRunner.setAcceptLanguages('fr-FR');
    done();
}, "Test the language change event fires on worker threads.");

async_test(function() {
    var worker = new Worker("resources/worker_language.js");
    var previous = navigator.languages
    worker.onmessage = this.step_func_done(function(e) {
        assert_equals(e.data, previous);
    });
    worker.postMessage("same language");
     worker.onmessage = this.step_func_done(function(e) {
        assert_not_equals(e.data, previous);
     });
    testRunner.setAcceptLanguages('fr-FR');
    worker.postMessage("different language");
    done();
}, "Test caching behavior on worker threads");

</script>
</body>
</html>
